package part9;

/**
 * @author wcj
 * @Date 2021/5/17 16:26
 * @Version 1.0
 */
public class Part91 {

    public static void main(String[] args) {
        BaseInstrument[] n = {
                new Wind(),
                new Brass(),
                new WoodWind()
        };
        tuneAll(n);
    }

    public static void tune(BaseInstrument i) {
        i.play(Note.MIDDLE);
    }

    public static void tuneAll(BaseInstrument[] b) {
        for (BaseInstrument baseInstrument : b) {
            tune(baseInstrument);
        }
    }
}

enum Note {
    /**
     * MIDDLE
     */
    MIDDLE,
    /**
     * LARGE
     */
    LARGE,
    /**
     * LARGER
     */
    LARGER,
}

/**
 * 抽象类命名,以Abstract或者Base开头
 * 抽象类使用abstract关键字进行修饰
 * 含有抽象方法的类一定是抽象类
 * 抽象类不一定含有抽象方法
 * 抽象方法不具有方法体
 * 导出类需要实现抽象方法
 */
abstract class BaseInstrument {
    private int i;

    /**
     * play
     *
     * @param n
     */
    public abstract void play(Note n);

    public String what() {
        return "Instrument";
    }

    /**
     * adjust
     */
    public abstract void adjust();
}

class Wind extends BaseInstrument {

    @Override
    public void play(Note n) {
        System.out.println("Wind play:" + n);
    }

    @Override
    public void adjust() {
    }

    @Override
    public String what() {
        return "Wind";
    }
}

class Brass extends BaseInstrument {

    @Override
    public void play(Note n) {
        System.out.println("Brass play:" + n);
    }

    @Override
    public void adjust() {

    }

    @Override
    public String what() {
        return "Brass";
    }
}

class WoodWind extends Wind {
    @Override
    public void play(Note n) {
        System.out.println("WoodWind play:" + n);
    }

    @Override
    public void adjust() {
    }

    @Override
    public String what() {
        return "WoodWind";
    }
}
